package com.kujie.access.domain.po;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kujie.access.domain.vo.PropertyListManageVO;
import com.kujie.common.core.validate.EditGroup;
import com.kujie.common.tenant.core.TenantEntity;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = true)
@TableName("access_property_list_management")
public class PropertyListManagement extends TenantEntity implements Serializable {
    /**
     * id
     */
    @NotNull(message = "id不能为空", groups = { EditGroup.class })
    private Long id;

    /**
     * access_region_management表中的index_code
     */
    private String indexCode;

    /**
     * 房源uuid
     */
    @TableField("property_uuid")
    private String propertyUUID;

    /**
     * 房源房号
     */
    private String roomNumber;

    /**
     * 房源面积，单位平方米
     */
    private String area;

//    /**
//     * 房源户型
//     */
//    private String houseType;

    /**
     * 房源租赁状态(空置、已租、已售出、装修中、预定)
     */
    private String leaseType;

    /**
     * 房源租赁用途(商业、办公等)
     */
    private String purpose;

//    /**
//     * 房源朝向
//     */
//    private String propertyOrientation;

    /**
     * 配套设施
     */
    private String supportFacilities;

    /**
     * 租金以平方米的价格为单位
     */
    private String rent;

    /**
     * 房源售价
     */
    private String price;

    /**
     * 房源平面图
     */
    private String floorPlan;

    public PropertyListManagement() {

    }

    public PropertyListManagement(Long id, String indexCode, String propertyUUID, String roomNumber, String area, String leaseType, String purpose, String supportFacilities, String rent, String price, String floorPlan) {
        this.id = id;
        this.indexCode = indexCode;
        this.propertyUUID = propertyUUID;
        this.roomNumber = roomNumber;
        this.area = area;
//        this.houseType = houseType;
        this.leaseType = leaseType;
        this.purpose = purpose;
//        this.propertyOrientation = propertyOrientation;
        this.supportFacilities = supportFacilities;
        this.rent = rent;
        this.price = price;
        this.floorPlan = floorPlan;
    }

    public PropertyListManagement(PropertyListManageVO propertyListManageVO, Map<String, String> nameToIndexCode) {
        this.indexCode = nameToIndexCode.get(propertyListManageVO.getBelongArea()) ;
        this.propertyUUID = IdUtil.randomUUID();
        this.roomNumber = propertyListManageVO.getRoomNumber();
        this.area = propertyListManageVO.getArea();
//        this.houseType = propertyListManageVO.getHouseType();
        this.leaseType = propertyListManageVO.getLeaseType();
        this.purpose = propertyListManageVO.getPurpose();
//        this.propertyOrientation = propertyListManageVO.getPropertyOrientation();
        this.supportFacilities = propertyListManageVO.getSupportFacilities();
        this.rent = propertyListManageVO.getRent();
        this.price = propertyListManageVO.getPrice();
        this.floorPlan = propertyListManageVO.getFloorPlan();
    }
}
